<template>
  <div class="form-wrap">
    <div class="clearfix title">
      <span class="h3">钉钉用户</span>
      {{ title }}
    </div>
    <keep-alive >
      <router-view
        :table-title="tableTitle"
        :table-data="tableData"
        :create-path="createPath"
        :creatable="false"
        :get-table-list="getTableList"
        :deletable="false"
        :readable="true"
        @childTitle="childTitle"
        @edit="edit"
      />
    </keep-alive>
  </div>

</template>

<script>

export default {
  data() {
    return {
      title: '',
      createPath: 'ding_manage.create',
      tableTitle: [
        {
          cn: 'id',
          en: 'userid'
        },
        {
          cn: '姓名',
          en: 'ddname'
        },
        {
          cn: '电话',
          en: 'mobile'
        },
        {
          cn: '头像',
          en: 'avatar',
          type: 'img'
        },
        {
          cn: '部门',
          en: 'name'
        },
        {
          cn: '更新时间',
          en: 'updated_at'
        }
      ],
      tableData: []
    }
  },
  methods: {

    getTableList(data, pageInfo) {
      this.$get('action/DingUser/dataGrid', data).then(res => {
        console.log(res)
        const list = res.data.list || []
        pageInfo.totalPage = res.data.totalPage
        pageInfo.totalRow = res.data.totalRow

        this.tableData = list || {}
      })
    },

    childTitle(val) {
      // console.log(val,'title');
      this.title = val
    },
    edit(val) {
      this.$router.push({
        name: 'ding_manage.edit',
        params: {
          details: val.row
        }
      })
    }
  }
}
</script>

<style scoped rel="stylesheet/scss" lang="scss">
    .form-wrap{
        padding:0 15px;
        .title{
            padding: 15px 0;
        }
    }
</style>
